<template>
	<view>
			<uni-card 
			v-for="(item,index) in auditionApplications" :key="index"
			:title="item.courseId" 
			:sub-title="item.applicationType==1?'类型：线下':'类型：线上'" 
			:extra="item.applicationStatus==0?'待审核':(item.applicationStatus==1?'已通过':'未通过')" 
			:thumbnail="avatar" 
			spacing="10px"
			@click="onClick">
			<text class="uni-body" style="color: #8F939C;">申请时间时间：{{item.applicationDatetime}}</text>
			</uni-card>
			
			<!-- 加载状态显示 -->
			<uni-load-more 
			iconType="circle" 
			:status="status" 
			:content-text="contentText"
			@click="clickLoadMore()"/>
			
			
	</view>
</template>

<script>
	export default {
		data() {
			return {
					avatar: '/static/logo.png',
					extraIcon:{
						color: '#4cd964',
						size: '22',
						type: 'gear-filled'
					},
					contentText: {
						contentdown: '查看更多',
						contentrefresh: '加载中',
						contentnomore: '没有更多'
					},
					status: 'loading',
					userInfo:{
						userId:''
					},
					pageInfo:{
						pageNo:1,
						pageSize:5,
					},
					auditionApplications:[],
					Urls:{
						//展示用户对应的试听预约
						"showAuditionApplicationByUserId":"/audition/auditionApplication/showAuditionApplicationByUserId",
					},
			}
		},
		methods: {
			onClick(e){
				console.log(e)
			},
			actionsClick(text){
				uni.showToast({
					title:text,
					icon:'none'
				})
			},
			/* 瀑布流-查看更多 */
			/* 回显0-5页的试听预约 */
			showAuditionApplicationByUserId(){
				
				this.$axios.post(this.Urls.showAuditionApplicationByUserId+"?userId="+this.userInfo.userId+"&pageNo="+this.pageInfo.pageNo+"&pageSize="+this.pageInfo.pageSize).then(res=>{
					console.log(res)
					if(res.data.success){
						this.auditionApplications=res.data.result.records;
						if(res.data.result.records.length==0){
							this.status='noMore';
						}else{
							this.status='more';
						}
						
					}
				});
			},
			/* 睡眠方法 */
			sleep (time) {
			  return new Promise((resolve) => setTimeout(resolve, time));
			}
				
		},
		onLoad(option) {
			
			this.userInfo.userId=option.userId;
			console.log(this.userInfo.userId)
		},
		created() {
			this.showAuditionApplicationByUserId();
		},
		onReachBottom(){	
			/* 瀑布流  回显下一页的试听预约 */
			this.status='loading';
			this.pageInfo.pageNo++;
			
			this.sleep(2000).then(() => {
			    // 这里写sleep之后需要去做的事情
				
				this.$axios.post(this.Urls.showAuditionApplicationByUserId+"?userId="+this.userInfo.userId+"&pageNo="+this.pageInfo.pageNo+"&pageSize="+this.pageInfo.pageSize).then(res=>{
					console.log(res)
					if(res.data.success){
						this.auditionApplications=this.auditionApplications.concat(res.data.result.records);
						if(res.data.result.records.length==0){
							this.status='noMore';
						}else{
							this.status='more';
						}
						
					}
				});
			})
			
		}
	}
</script>

<style>

</style>
